/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Vista;

/**
 *
 * @author Nyappy
 */
import Controlador.*;
import Modelo.Paciente;
import Modelo.Medico;
import Modelo.Medicamento;
import Modelo.Usuario;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JOptionPane;
import java.util.ArrayList;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

public class IUAdministrador extends javax.swing.JFrame {

    /**
     * Creates new form Administrador
     */
//    public Archivo a1;
//    public ArrayList<Paciente> Pacientes;
    public Factory fact;
    int indice = 0;
    int indiceMedicos = 0;
    int indiceMedicamentos = 0;
    int indiceAlergias = 0;
    int indiceUsuarios = 0;

    public IUAdministrador() {        
        initComponents();
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
//        fact = new Factory();
//        fact.getInstance();
//        String sDirAct = System.getProperty("user.dir");
//        System.out.println("sDirAct: " + sDirAct);
//        a1 = new Archivo(sDirAct + "/Pacientes.txt");
//         if(a1.leer()!=null)
//            Pacientes=(ArrayList<Paciente>)a1.leer();
//        else
//            Pacientes=new ArrayList<Paciente>();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        tpPacientes = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        tfNombreDoc = new javax.swing.JTextField();
        tfApPatDoc = new javax.swing.JTextField();
        tfApMatDoc = new javax.swing.JTextField();
        tfNumCed = new javax.swing.JTextField();
        tfEspecialidad = new javax.swing.JTextField();
        registrarDoc = new javax.swing.JButton();
        eliminarDoc = new javax.swing.JButton();
        atrasDoc = new javax.swing.JButton();
        adelanteDoc = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        cambiosMedicos = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        tfNomMedicamento = new javax.swing.JTextField();
        tfPresentacion = new javax.swing.JTextField();
        tfSubsAct = new javax.swing.JTextField();
        registrarMedicamento = new javax.swing.JButton();
        atrasMedicamentos = new javax.swing.JButton();
        eliMedicamentos = new javax.swing.JButton();
        adelanteMedicamentos = new javax.swing.JButton();
        jLabel20 = new javax.swing.JLabel();
        cambiosMedicamentos = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        tfUsuNom = new javax.swing.JTextField();
        regUsu = new javax.swing.JButton();
        EliUsu = new javax.swing.JButton();
        tfUsuPass = new javax.swing.JPasswordField();
        atrasUsu = new javax.swing.JButton();
        adelanteUsu = new javax.swing.JButton();
        cambiosUsuarios = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        tfNombre = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tfEdad = new javax.swing.JTextField();
        tfAlergias = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        tfApPaterno = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        tfTipoSangre = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        tfPeso = new javax.swing.JTextField();
        tfEstatura = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tfPresion = new javax.swing.JTextField();
        registrar = new javax.swing.JButton();
        eliminar = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        tfApMaterno = new javax.swing.JTextField();
        cbFamHip = new javax.swing.JCheckBox();
        cbFamDia = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        tfPadecimientos = new javax.swing.JTextField();
        bAtras = new javax.swing.JButton();
        bAdelante = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator5 = new javax.swing.JSeparator();
        jLabel26 = new javax.swing.JLabel();
        jSeparator6 = new javax.swing.JSeparator();
        jSeparator7 = new javax.swing.JSeparator();
        jSeparator8 = new javax.swing.JSeparator();
        jSeparator9 = new javax.swing.JSeparator();
        cambiosPacientes = new javax.swing.JButton();
        btSeleccionar = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        lFoto = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(610, 550));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel3.setBackground(new java.awt.Color(0, 153, 153));

        jLabel11.setText("Nombre");

        jLabel12.setText("Apellido Paterno");

        jLabel13.setText("Apellido Materno");

        jLabel14.setText("Número Cédula");

        jLabel15.setText("Especialidad");

        tfNombreDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNombreDocActionPerformed(evt);
            }
        });

        tfApPatDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfApPatDocActionPerformed(evt);
            }
        });

        registrarDoc.setBackground(new java.awt.Color(51, 0, 51));
        registrarDoc.setForeground(new java.awt.Color(255, 255, 255));
        registrarDoc.setText("Registrar");
        registrarDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarDocActionPerformed(evt);
            }
        });

        eliminarDoc.setBackground(new java.awt.Color(51, 0, 0));
        eliminarDoc.setForeground(new java.awt.Color(255, 255, 255));
        eliminarDoc.setText("Eliminar");
        eliminarDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarDocActionPerformed(evt);
            }
        });

        atrasDoc.setText("<<");
        atrasDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atrasDocActionPerformed(evt);
            }
        });

        adelanteDoc.setText(">>");
        adelanteDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adelanteDocActionPerformed(evt);
            }
        });

        jLabel19.setText("REGISTRO DE MEDICOS");

        cambiosMedicos.setBackground(new java.awt.Color(51, 51, 0));
        cambiosMedicos.setForeground(new java.awt.Color(255, 255, 255));
        cambiosMedicos.setText("Actualizar");
        cambiosMedicos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiosMedicosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel11))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(tfApPatDoc, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                                    .addComponent(tfNombreDoc)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfApMatDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(atrasDoc)
                                        .addGap(18, 18, 18)
                                        .addComponent(adelanteDoc)))))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel15)
                                    .addComponent(registrarDoc))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(eliminarDoc)
                                    .addComponent(tfEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfNumCed, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(73, 73, 73)
                                .addComponent(cambiosMedicos))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(194, 194, 194)
                        .addComponent(jLabel19)))
                .addContainerGap(1547, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jLabel19)
                .addGap(55, 55, 55)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(24, 24, 24)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(tfApPatDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(tfApMatDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(atrasDoc)
                            .addComponent(adelanteDoc)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(tfEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tfNombreDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(tfNumCed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(registrarDoc)
                            .addComponent(eliminarDoc))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cambiosMedicos)))
                .addContainerGap(547, Short.MAX_VALUE))
        );

        tpPacientes.addTab("Medicos", jPanel3);

        jPanel4.setBackground(new java.awt.Color(0, 153, 153));

        jLabel16.setText("Nombre");

        jLabel17.setText("Presentación");

        jLabel18.setText("Substancia Activa");

        registrarMedicamento.setBackground(new java.awt.Color(51, 0, 51));
        registrarMedicamento.setForeground(new java.awt.Color(255, 255, 255));
        registrarMedicamento.setText("Registrar");
        registrarMedicamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarMedicamentoActionPerformed(evt);
            }
        });

        atrasMedicamentos.setText("<<");
        atrasMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atrasMedicamentosActionPerformed(evt);
            }
        });

        eliMedicamentos.setBackground(new java.awt.Color(51, 0, 0));
        eliMedicamentos.setForeground(new java.awt.Color(255, 255, 255));
        eliMedicamentos.setText("Eliminar");
        eliMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliMedicamentosActionPerformed(evt);
            }
        });

        adelanteMedicamentos.setText(">>");
        adelanteMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adelanteMedicamentosActionPerformed(evt);
            }
        });

        jLabel20.setText("REGISTRO DE MEDICAMENTOS");

        cambiosMedicamentos.setBackground(new java.awt.Color(51, 51, 0));
        cambiosMedicamentos.setForeground(new java.awt.Color(255, 255, 255));
        cambiosMedicamentos.setText("Actualizar");
        cambiosMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiosMedicamentosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(151, 151, 151)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel16)
                                    .addComponent(jLabel17))
                                .addGap(60, 60, 60)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfPresentacion, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfNomMedicamento, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel18)
                                .addGap(29, 29, 29)
                                .addComponent(tfSubsAct, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(172, 172, 172)
                        .addComponent(jLabel20))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(114, 114, 114)
                        .addComponent(atrasMedicamentos)
                        .addGap(18, 18, 18)
                        .addComponent(adelanteMedicamentos)
                        .addGap(28, 28, 28)
                        .addComponent(registrarMedicamento)
                        .addGap(18, 18, 18)
                        .addComponent(eliMedicamentos))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(309, 309, 309)
                        .addComponent(cambiosMedicamentos)))
                .addContainerGap(1580, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabel20)
                .addGap(35, 35, 35)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(tfNomMedicamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(tfPresentacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(tfSubsAct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(atrasMedicamentos)
                    .addComponent(adelanteMedicamentos)
                    .addComponent(registrarMedicamento)
                    .addComponent(eliMedicamentos))
                .addGap(18, 18, 18)
                .addComponent(cambiosMedicamentos)
                .addContainerGap(474, Short.MAX_VALUE))
        );

        tpPacientes.addTab("Medicamentos", jPanel4);

        jPanel5.setBackground(new java.awt.Color(0, 153, 153));

        jLabel22.setText("Registro de Usuarios");

        jLabel23.setText("Nombre");

        jLabel24.setText("Contraseña");

        tfUsuNom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfUsuNomActionPerformed(evt);
            }
        });

        regUsu.setBackground(new java.awt.Color(51, 0, 51));
        regUsu.setForeground(new java.awt.Color(255, 255, 255));
        regUsu.setText("Registrar");
        regUsu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                regUsuActionPerformed(evt);
            }
        });

        EliUsu.setBackground(new java.awt.Color(51, 0, 0));
        EliUsu.setForeground(new java.awt.Color(255, 255, 255));
        EliUsu.setText("Eliminar");
        EliUsu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EliUsuActionPerformed(evt);
            }
        });

        tfUsuPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfUsuPassActionPerformed(evt);
            }
        });

        atrasUsu.setText("<<");
        atrasUsu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atrasUsuActionPerformed(evt);
            }
        });

        adelanteUsu.setText(">>");
        adelanteUsu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adelanteUsuActionPerformed(evt);
            }
        });

        cambiosUsuarios.setBackground(new java.awt.Color(51, 51, 0));
        cambiosUsuarios.setForeground(new java.awt.Color(255, 255, 255));
        cambiosUsuarios.setText("Actualizar");
        cambiosUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiosUsuariosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(regUsu)
                        .addGap(18, 18, 18)
                        .addComponent(EliUsu)
                        .addGap(30, 30, 30)
                        .addComponent(atrasUsu)
                        .addGap(18, 18, 18)
                        .addComponent(adelanteUsu))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(123, 123, 123)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel23)
                            .addComponent(jLabel24))
                        .addGap(39, 39, 39)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tfUsuNom)
                            .addComponent(tfUsuPass, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(193, 193, 193)
                        .addComponent(jLabel22))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(130, 130, 130)
                        .addComponent(cambiosUsuarios)))
                .addContainerGap(1611, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabel22)
                .addGap(37, 37, 37)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(tfUsuNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(tfUsuPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EliUsu)
                    .addComponent(regUsu)
                    .addComponent(atrasUsu)
                    .addComponent(adelanteUsu))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cambiosUsuarios)
                .addContainerGap(495, Short.MAX_VALUE))
        );

        tpPacientes.addTab("Usuarios", jPanel5);

        jPanel1.setBackground(new java.awt.Color(0, 153, 153));
        jPanel1.setMaximumSize(new java.awt.Dimension(33000, 32767));

        jLabel2.setText("Nombre");

        jLabel3.setText("Edad");

        jLabel4.setText("Alergias");

        jLabel5.setText("Apellido Paterno");

        jLabel6.setText("Tipo sangre");

        jLabel7.setText("Peso");

        jLabel8.setText("Estatura");

        jLabel9.setText("Presión");

        registrar.setBackground(new java.awt.Color(51, 0, 51));
        registrar.setForeground(new java.awt.Color(255, 255, 255));
        registrar.setText("Registrar");
        registrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarActionPerformed(evt);
            }
        });

        eliminar.setBackground(new java.awt.Color(51, 0, 0));
        eliminar.setForeground(new java.awt.Color(255, 255, 255));
        eliminar.setText("Eliminar");
        eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarActionPerformed(evt);
            }
        });

        jLabel10.setText("Apellido Materno");

        cbFamHip.setText("Familia Hipertensa");
        cbFamHip.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbFamHipActionPerformed(evt);
            }
        });

        cbFamDia.setText("Familia Diabética");

        jLabel1.setText("Padecimientos");

        bAtras.setText("<<");
        bAtras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAtrasActionPerformed(evt);
            }
        });

        bAdelante.setText(">>");
        bAdelante.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAdelanteActionPerformed(evt);
            }
        });

        jLabel21.setText("REGISTRO DE PACIENTES");

        jLabel25.setText("DATOS GENERALES");

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel26.setText("HISTORIAL MEDICO");

        jSeparator6.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jSeparator9.setOrientation(javax.swing.SwingConstants.VERTICAL);

        cambiosPacientes.setBackground(new java.awt.Color(51, 51, 0));
        cambiosPacientes.setForeground(new java.awt.Color(255, 255, 255));
        cambiosPacientes.setText("Actualizar");
        cambiosPacientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiosPacientesActionPerformed(evt);
            }
        });

        btSeleccionar.setText("Seleccionar");
        btSeleccionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSeleccionarActionPerformed(evt);
            }
        });

        jLabel27.setText("Subir foto:");

        lFoto.setText("No hay foto seleccionada");
        lFoto.setToolTipText("");
        lFoto.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(51, 0, 51), null, null));
        lFoto.setMaximumSize(new java.awt.Dimension(131, 111));
        lFoto.setMinimumSize(new java.awt.Dimension(131, 111));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(194, 194, 194)
                .addComponent(jLabel21)
                .addGap(0, 1683, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel26)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jSeparator7)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(jLabel1)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(tfPadecimientos, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                                            .addComponent(jLabel9)
                                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                            .addComponent(tfPresion))
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                                            .addComponent(jLabel4)
                                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                            .addComponent(tfAlergias, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                                .addGap(30, 30, 30)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(cbFamHip)
                                                    .addComponent(cbFamDia)
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(registrar)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                        .addComponent(eliminar))
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(bAtras)
                                                        .addGap(18, 18, 18)
                                                        .addComponent(bAdelante)
                                                        .addGap(18, 18, 18)
                                                        .addComponent(cambiosPacientes))))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(72, 72, 72)
                                                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jSeparator4)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(18, 18, 18)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel2)
                                                .addComponent(jLabel5)
                                                .addComponent(jLabel10)))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(18, 18, 18)
                                            .addComponent(jLabel6)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(tfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(tfApMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(tfApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(tfTipoSangre, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(44, 44, 44)
                                            .addComponent(jLabel27)
                                            .addGap(41, 41, 41)
                                            .addComponent(btSeleccionar))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(40, 40, 40)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel8)
                                                .addComponent(jLabel7)
                                                .addComponent(jLabel3))
                                            .addGap(18, 18, 18)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(tfEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(tfPeso, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(tfEstatura, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(lFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel25)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jSeparator2)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel25))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(12, 12, 12)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel2)
                                            .addComponent(tfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel5)
                                            .addComponent(tfApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel10)
                                            .addComponent(tfApMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(tfTipoSangre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel6)))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(20, 20, 20)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(tfEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(tfPeso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel7))
                                        .addGap(24, 24, 24)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel8)
                                            .addComponent(tfEstatura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(lFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btSeleccionar)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jSeparator6)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(cbFamHip)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(cbFamDia)
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(bAtras)
                                            .addComponent(bAdelante)
                                            .addComponent(cambiosPacientes))
                                        .addGap(27, 27, 27)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(registrar)
                                            .addComponent(eliminar)))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(tfPadecimientos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4)
                                    .addComponent(tfAlergias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel9)
                                    .addComponent(tfPresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(355, Short.MAX_VALUE))
        );

        tpPacientes.addTab("Pacientes", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1186, 1186, 1186))
            .addGroup(layout.createSequentialGroup()
                .addComponent(tpPacientes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tpPacientes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(188, 188, 188))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void registrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarActionPerformed
        // TODO add your handling code here:
        ArrayList<String> alAlergias = new ArrayList<String>();
        String nombre= tfNombre.getText();
        String apPaterno= tfApPaterno.getText();
        int peso = Integer.parseInt(tfPeso.getText());
        int estatura = Integer.parseInt(tfEstatura.getText());
        int edad= Integer.parseInt(tfEdad.getText());
        String TipoSangre = tfTipoSangre.getText();
        String Nombre = tfNombre.getText();
        String apMaterno = tfApMaterno.getText();
        String direccion=lFoto.getText();
        Paciente pac = new Paciente(edad,peso,estatura,TipoSangre,nombre,apPaterno,apMaterno,direccion);
        
        String presion = tfPresion.getText();
        alAlergias.add(tfAlergias.getText());
        String padecimientos = tfPadecimientos.getText();
        boolean FamHip;
        boolean FamDia;
        if(cbFamHip.isSelected()==true)
            FamHip = true;
        else
            FamHip = false;
        if(cbFamDia.isSelected()==true)
            FamDia = true;
        else
            FamDia = false;
        
        
        Paciente.Historial h = pac.new Historial(presion,alAlergias,padecimientos,FamHip,FamDia);
        pac.setHistorialMedico(h);
//        alPacientes = fact.getPacientes();
//        alPacientes.add(pac);
//        fact.setPacientes(alPacientes);
//        fact.Guardar();
        //fact.setPacientes(pac);
        fact.getInstance().crear(pac);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Paciente agregado con éxito ");
        
        tfNombre.setText("");
        tfApPaterno.setText("");
        tfEdad.setText("");
        tfPresion.setText("");
        tfAlergias.setText("");
        tfTipoSangre.setText("");
        tfPeso.setText("");
        tfEstatura.setText("");
        tfApMaterno.setText("");
        tfPadecimientos.setText("");
        cbFamHip.setSelected(false);
        cbFamDia.setSelected(false);
        lFoto.setText("No hay imagen seleccionada");
        lFoto.setIcon(null);
    }//GEN-LAST:event_registrarActionPerformed

    private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarActionPerformed
        // TODO add your handling code here:        
        fact.getInstance().eliminar(fact.getInstance().getPacientes().get(indice));
        indice = 0;
        fact.getInstance().Guardar();
        
        JOptionPane.showMessageDialog(null,"Paciente eliminado");
        
        tfNombre.setText("");
        tfApPaterno.setText("");
        tfEdad.setText("");
        tfPresion.setText("");
        tfAlergias.setText("");
        tfTipoSangre.setText("");
        tfPeso.setText("");
        tfEstatura.setText("");
        tfApMaterno.setText("");
        tfPadecimientos.setText("");
        cbFamHip.setSelected(false);
        cbFamDia.setSelected(false);
        lFoto.setText("No hay imagen seleccionada");
        lFoto.setIcon(null);
       
    }//GEN-LAST:event_eliminarActionPerformed

    private void bAtrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAtrasActionPerformed
        // TODO add your handling code here:
       if(indice == 0)
        indice= fact.getInstance().getPacientes().size()-1;
       else
        indice -=1;
       if(indice >= 0 && indice <= fact.getInstance().getPacientes().size()-1){
        tfNombre.setText (fact.getInstance().getPacientes().get(indice).getNombre());
        tfApPaterno.setText (fact.getInstance().getPacientes().get(indice).getApellidoPaterno());
        tfEdad.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getEdad()));
        tfApMaterno.setText (fact.getInstance().getPacientes().get(indice).getApellidoMaterno());
        tfTipoSangre.setText (fact.getInstance().getPacientes().get(indice).getTipoSangre());
        tfPeso.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getPeso()));
        tfEstatura.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getEstatura()));
         lFoto.setIcon(new ImageIcon(fact.getInstance().getPacientes().get(indice).getFoto()));
         lFoto.setText(fact.getInstance().getPacientes().get(indice).getFoto());
        tfPresion.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getPresion());                     
        tfPadecimientos.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getPadecimientos());
         if (indiceAlergias == fact.getInstance().getPacientes().get(indice).getHistorialMedico().getAlergias().size()-1) {
             indiceAlergias = 0;
         }
         else
             indiceAlergias += 1;
         tfAlergias.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getAlergias().get(indiceAlergias));
         cbFamDia.setSelected(fact.getInstance().getPacientes().get(indice).getHistorialMedico().isFamiliaDiabetes());
         cbFamHip.setSelected(fact.getInstance().getPacientes().get(indice).getHistorialMedico().isFamiliaHipertension());
       }
       else
           indice = 0;   
    }//GEN-LAST:event_bAtrasActionPerformed

    private void tfNombreDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNombreDocActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfNombreDocActionPerformed

    private void tfApPatDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfApPatDocActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfApPatDocActionPerformed

    private void bAdelanteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAdelanteActionPerformed
        // TODO add your handling code here:
        if(indice == fact.getInstance().getPacientes().size()-1)
        indice= 0;
       else
        indice +=1;
       if(indice >= 0 && indice <= fact.getInstance().getPacientes().size()-1){ 
        tfNombre.setText (fact.getInstance().getPacientes().get(indice).getNombre());
        tfApPaterno.setText (fact.getInstance().getPacientes().get(indice).getApellidoPaterno());
        tfEdad.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getEdad()));
        tfApMaterno.setText (fact.getInstance().getPacientes().get(indice).getApellidoMaterno());
        tfTipoSangre.setText (fact.getInstance().getPacientes().get(indice).getTipoSangre());
        tfPeso.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getPeso()));
        tfEstatura.setText (Integer.toString(fact.getInstance().getPacientes().get(indice).getEstatura()));
        lFoto.setIcon(new ImageIcon(fact.getInstance().getPacientes().get(indice).getFoto()));
        lFoto.setText(fact.getInstance().getPacientes().get(indice).getFoto());
        tfPresion.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getPresion());                     
        tfPadecimientos.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getPadecimientos());
         if (indiceAlergias == fact.getInstance().getPacientes().get(indice).getHistorialMedico().getAlergias().size()-1) {
             indiceAlergias = 0;
         }
         else
             indiceAlergias += 1;
         tfAlergias.setText (fact.getInstance().getPacientes().get(indice).getHistorialMedico().getAlergias().get(indiceAlergias));
         cbFamDia.setSelected(fact.getInstance().getPacientes().get(indice).getHistorialMedico().isFamiliaDiabetes());
         cbFamHip.setSelected(fact.getInstance().getPacientes().get(indice).getHistorialMedico().isFamiliaHipertension());
       }
       else
           indice = 0;
    }//GEN-LAST:event_bAdelanteActionPerformed

    private void registrarDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarDocActionPerformed
        // TODO add your handling code here:
        String nombre = tfNombreDoc.getText();
        String apPaterno = tfApPatDoc.getText();
        String apMaterno = tfApMatDoc.getText();
        String cedula = tfNumCed.getText();
        String especialidad = tfEspecialidad.getText();
        Medico med = new Medico(especialidad,cedula,nombre,apPaterno,apMaterno);
        fact.getInstance().crear(med);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Médico Agragado Con Éxito");
        
        tfNombreDoc.setText("");
        tfApPatDoc.setText("");
        tfApMatDoc.setText("");
        tfNumCed.setText("");
        tfEspecialidad.setText("");
    }//GEN-LAST:event_registrarDocActionPerformed

    private void atrasDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atrasDocActionPerformed
        // TODO add your handling code here:
        if(indiceMedicos == 0)
        indiceMedicos= fact.getInstance().getMedicos().size()-1;
       else
        indiceMedicos -=1;
        if (indiceMedicos >= 0 && indiceMedicos <= fact.getInstance().getMedicos().size()-1) {        
            tfNombreDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getNombre());
            tfApPatDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getApellidoPaterno());       
            tfApMatDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getApellidoMaterno());
            tfNumCed.setText (fact.getInstance().getMedicos().get(indiceMedicos).getNumCedula());
            tfEspecialidad.setText (fact.getInstance().getMedicos().get(indiceMedicos).getEspecialidad());
        }
        else
            indiceMedicos = 0;
    }//GEN-LAST:event_atrasDocActionPerformed

    private void adelanteDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adelanteDocActionPerformed
        // TODO add your handling code here:
        if(indiceMedicos == fact.getInstance().getMedicos().size()-1)
        indiceMedicos= 0;
       else
        indiceMedicos +=1;
       if(indiceMedicos >= 0 && indiceMedicos <= fact.getInstance().getMedicos().size()-1){
        tfNombreDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getNombre());
        tfApPatDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getApellidoPaterno());       
        tfApMatDoc.setText (fact.getInstance().getMedicos().get(indiceMedicos).getApellidoMaterno());
        tfNumCed.setText (fact.getInstance().getMedicos().get(indiceMedicos).getNumCedula());
        tfEspecialidad.setText (fact.getInstance().getMedicos().get(indiceMedicos).getEspecialidad());
       }
       else
           indiceMedicos = 0;
    }//GEN-LAST:event_adelanteDocActionPerformed

    private void registrarMedicamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarMedicamentoActionPerformed
        // TODO add your handling code here:
        String nomMedicamento = tfNomMedicamento.getText();
        String presentacion = tfPresentacion.getText();
        String subsActiva = tfSubsAct.getText();
        Medicamento medica = new Medicamento(nomMedicamento,presentacion,subsActiva);
        fact.getInstance().crear(medica);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Medicamento agregado con éxito ");
        
        tfNomMedicamento.setText("");
        tfPresentacion.setText("");
        tfSubsAct.setText("");        
    }//GEN-LAST:event_registrarMedicamentoActionPerformed

    private void adelanteMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adelanteMedicamentosActionPerformed
        // TODO add your handling code here:
        if(indiceMedicamentos == fact.getInstance().getMedicamentos().size()-1)
        indiceMedicamentos= 0;
       else
        indiceMedicamentos +=1;
       if(indiceMedicamentos >= 0 && indiceMedicamentos <= fact.getInstance().getMedicamentos().size()-1){
        tfNomMedicamento.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getNombre());
        tfPresentacion.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getPresentacion());       
        tfSubsAct.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getSustanciaActiva());
       }
       else
           indiceMedicamentos = 0;
    }//GEN-LAST:event_adelanteMedicamentosActionPerformed

    private void atrasMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atrasMedicamentosActionPerformed
        // TODO add your handling code here:
        if(indiceMedicamentos == 0)
        indiceMedicamentos= fact.getInstance().getMedicamentos().size()-1;
       else
        indiceMedicamentos -=1;
       if(indiceMedicamentos >= 0 && indiceMedicamentos <= fact.getInstance().getMedicamentos().size()-1){
        tfNomMedicamento.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getNombre());
        tfPresentacion.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getPresentacion());       
        tfSubsAct.setText (fact.getInstance().getMedicamentos().get(indiceMedicamentos).getSustanciaActiva());
       }
       else
           indiceMedicamentos = 0;
    }//GEN-LAST:event_atrasMedicamentosActionPerformed

    private void cbFamHipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbFamHipActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbFamHipActionPerformed

    private void tfUsuNomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfUsuNomActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfUsuNomActionPerformed

    private void EliUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EliUsuActionPerformed
        // TODO add your handling code here:
        fact.getInstance().eliminar(fact.getInstance().getUsuarios().get(indiceUsuarios));
        indiceUsuarios = 0;
        fact.getInstance().Guardar();
        
        JOptionPane.showMessageDialog(null,"Usuario eliminado");
        
        tfUsuNom.setText("");
        tfUsuPass.setText(""); 
    }//GEN-LAST:event_EliUsuActionPerformed

    private void regUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_regUsuActionPerformed
        // TODO add your handling code here:
        String nombreUsuario = tfUsuNom.getText();
        String password = tfUsuPass.getText();
        Usuario user = new Usuario(nombreUsuario,password);
        fact.getInstance().crear(user);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Usuario agregado con éxito ");
        
        tfUsuNom.setText("");
        tfUsuPass.setText("");        
    }//GEN-LAST:event_regUsuActionPerformed

    private void atrasUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atrasUsuActionPerformed
        // TODO add your handling code here:
        if(indiceUsuarios == 0)
        indiceUsuarios= fact.getInstance().getUsuarios().size()-1;
       else
        indiceUsuarios -=1;
       if(indiceUsuarios >= 0 && indiceUsuarios <= fact.getInstance().getUsuarios().size()-1){
        tfUsuNom.setText (fact.getInstance().getUsuarios().get(indiceUsuarios).getNombre());
        tfUsuPass.setText (fact.getInstance().getUsuarios().get(indiceUsuarios).getContrasenia());
       }
       else
           indiceUsuarios = 0;
    }//GEN-LAST:event_atrasUsuActionPerformed

    private void adelanteUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adelanteUsuActionPerformed
        // TODO add your handling code here:
        if(indiceUsuarios == fact.getInstance().getUsuarios().size()-1)
        indiceUsuarios= 0;
       else
        indiceUsuarios +=1;
       if(indiceUsuarios >= 0 && indiceUsuarios <= fact.getInstance().getUsuarios().size()-1){
        tfUsuNom.setText (fact.getInstance().getUsuarios().get(indiceUsuarios).getNombre());
        tfUsuPass.setText (fact.getInstance().getUsuarios().get(indiceUsuarios).getContrasenia());
       }
       else
           indiceUsuarios = 0;
    }//GEN-LAST:event_adelanteUsuActionPerformed

    private void eliminarDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarDocActionPerformed
        // TODO add your handling code here:
        fact.getInstance().eliminar(fact.getInstance().getMedicos().get(indiceMedicos));
        indiceMedicos = 0;
        fact.getInstance().Guardar();
        
        JOptionPane.showMessageDialog(null,"Médico eliminado");
        
        tfNombreDoc.setText("");
        tfApPatDoc.setText("");
        tfApMatDoc.setText("");
        tfNumCed.setText("");
        tfEspecialidad.setText("");
    }//GEN-LAST:event_eliminarDocActionPerformed

    private void eliMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliMedicamentosActionPerformed
        // TODO add your handling code here:
        fact.getInstance().eliminar(fact.getInstance().getMedicamentos().get(indiceMedicamentos));
        indiceMedicamentos = 0;
        fact.getInstance().Guardar();
        
        JOptionPane.showMessageDialog(null,"Medicamento eliminado");
        
        tfNomMedicamento.setText("");
        tfPresentacion.setText("");
        tfSubsAct.setText(""); 
    }//GEN-LAST:event_eliMedicamentosActionPerformed

    private void cambiosPacientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cambiosPacientesActionPerformed
        // TODO add your handling code here:
        Paciente aux = fact.getInstance().getPacientes().get(indice);
        
        ArrayList<String> alAlergias = new ArrayList<String>();
        String nombre= tfNombre.getText();
        String apPaterno= tfApPaterno.getText();
        int peso = Integer.parseInt(tfPeso.getText());
        int estatura = Integer.parseInt(tfEstatura.getText());
        int edad= Integer.parseInt(tfEdad.getText());
        String TipoSangre = tfTipoSangre.getText();
        String Nombre = tfNombre.getText();
        String apMaterno = tfApMaterno.getText();
        String direccion=lFoto.getText();
        Paciente pac = new Paciente(edad,peso,estatura,TipoSangre,nombre,apPaterno,apMaterno,direccion);
        
        String presion = tfPresion.getText();
        alAlergias.add(tfAlergias.getText());
        String padecimientos = tfPadecimientos.getText();
        boolean FamHip;
        boolean FamDia;
        if(cbFamHip.isSelected()==true)
            FamHip = true;
        else
            FamHip = false;
        if(cbFamDia.isSelected()==true)
            FamDia = true;
        else
            FamDia = false;       
        
        Paciente.Historial h = pac.new Historial(presion,alAlergias,padecimientos,FamHip,FamDia);
        pac.setHistorialMedico(h);
        fact.getInstance().actualizar(aux,pac);
        fact.getInstance().Guardar();
        
        JOptionPane.showMessageDialog(null,"Se han actualizado los datos del paciente");
        lFoto.setText("No hay imagen seleccionada");
        lFoto.setIcon(null);
        tfNombre.setText("");
        tfApPaterno.setText("");
        tfEdad.setText("");
        tfPresion.setText("");
        tfAlergias.setText("");
        tfTipoSangre.setText("");
        tfPeso.setText("");
        tfEstatura.setText("");
        tfApMaterno.setText("");
        tfPadecimientos.setText("");
        cbFamHip.setSelected(false);
        cbFamDia.setSelected(false);
        
        
    }//GEN-LAST:event_cambiosPacientesActionPerformed

    private void cambiosMedicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cambiosMedicosActionPerformed
        // TODO add your handling code here:
        Medico aux = fact.getInstance().getMedicos().get(indiceMedicos);
        
        String nombre = tfNombreDoc.getText();
        String apPaterno = tfApPatDoc.getText();
        String apMaterno = tfApMatDoc.getText();
        String cedula = tfNumCed.getText();
        String especialidad = tfEspecialidad.getText();
        Medico med = new Medico(especialidad,cedula,nombre,apPaterno,apMaterno);
        fact.getInstance().actualizar(aux,med);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Datos del Médico Actualizados");
        
        tfNombreDoc.setText("");
        tfApPatDoc.setText("");
        tfApMatDoc.setText("");
        tfNumCed.setText("");
        tfEspecialidad.setText("");
    }//GEN-LAST:event_cambiosMedicosActionPerformed

    private void cambiosUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cambiosUsuariosActionPerformed
        // TODO add your handling code here:
        Usuario aux = fact.getInstance().getUsuarios().get(indiceUsuarios);
        String nombreUsuario = tfUsuNom.getText();
        String password = tfUsuPass.getText();
        Usuario user = new Usuario(nombreUsuario,password);
        fact.getInstance().actualizar(aux,user);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Datos de Usuario actualizados");
        
        tfUsuNom.setText("");
        tfUsuPass.setText("");
    }//GEN-LAST:event_cambiosUsuariosActionPerformed

    private void cambiosMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cambiosMedicamentosActionPerformed
        // TODO add your handling code here:
        Medicamento aux = fact.getInstance().getMedicamentos().get(indiceMedicamentos);
        String nomMedicamento = tfNomMedicamento.getText();
        String presentacion = tfPresentacion.getText();
        String subsActiva = tfSubsAct.getText();
        Medicamento medica = new Medicamento(nomMedicamento,presentacion,subsActiva);
        fact.getInstance().actualizar(aux,medica);
        fact.getInstance().Guardar();
        JOptionPane.showMessageDialog(null,"Datos de Medicamento actualizados");
        
        tfNomMedicamento.setText("");
        tfPresentacion.setText("");
        tfSubsAct.setText("");
    }//GEN-LAST:event_cambiosMedicamentosActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

        new LogIn().setVisible(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing

    private void btSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSeleccionarActionPerformed
        // TODO add your handling code here:
    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter(
        "JPG & GIF Images", "jpg", "gif");
    chooser.setFileFilter(filter);
 
    int returnVal = chooser.showOpenDialog(chooser.getParent());
    if(returnVal == JFileChooser.APPROVE_OPTION) 
    {
        String dir=chooser.getSelectedFile().getAbsolutePath();
        lFoto.setIcon(new ImageIcon(dir));
        lFoto.setText(dir);
    }
   
    }//GEN-LAST:event_btSeleccionarActionPerformed

    private void tfUsuPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfUsuPassActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfUsuPassActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IUAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IUAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IUAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IUAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IUAdministrador().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton EliUsu;
    private javax.swing.JButton adelanteDoc;
    private javax.swing.JButton adelanteMedicamentos;
    private javax.swing.JButton adelanteUsu;
    private javax.swing.JButton atrasDoc;
    private javax.swing.JButton atrasMedicamentos;
    private javax.swing.JButton atrasUsu;
    private javax.swing.JButton bAdelante;
    private javax.swing.JButton bAtras;
    private javax.swing.JButton btSeleccionar;
    private javax.swing.JButton cambiosMedicamentos;
    private javax.swing.JButton cambiosMedicos;
    private javax.swing.JButton cambiosPacientes;
    private javax.swing.JButton cambiosUsuarios;
    private javax.swing.JCheckBox cbFamDia;
    private javax.swing.JCheckBox cbFamHip;
    private javax.swing.JButton eliMedicamentos;
    private javax.swing.JButton eliminar;
    private javax.swing.JButton eliminarDoc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JLabel lFoto;
    private javax.swing.JButton regUsu;
    private javax.swing.JButton registrar;
    private javax.swing.JButton registrarDoc;
    private javax.swing.JButton registrarMedicamento;
    private javax.swing.JTextField tfAlergias;
    private javax.swing.JTextField tfApMatDoc;
    private javax.swing.JTextField tfApMaterno;
    private javax.swing.JTextField tfApPatDoc;
    private javax.swing.JTextField tfApPaterno;
    private javax.swing.JTextField tfEdad;
    private javax.swing.JTextField tfEspecialidad;
    private javax.swing.JTextField tfEstatura;
    private javax.swing.JTextField tfNomMedicamento;
    private javax.swing.JTextField tfNombre;
    private javax.swing.JTextField tfNombreDoc;
    private javax.swing.JTextField tfNumCed;
    private javax.swing.JTextField tfPadecimientos;
    private javax.swing.JTextField tfPeso;
    private javax.swing.JTextField tfPresentacion;
    private javax.swing.JTextField tfPresion;
    private javax.swing.JTextField tfSubsAct;
    private javax.swing.JTextField tfTipoSangre;
    private javax.swing.JTextField tfUsuNom;
    private javax.swing.JPasswordField tfUsuPass;
    private javax.swing.JTabbedPane tpPacientes;
    // End of variables declaration//GEN-END:variables
}
